const express = require('express')
const multer = require('multer')
const expressJoi = require('@escook/express-joi')
const path = require('path')

const { addArticle } = require('../router_handler/article')
const { addArticleRuler } = require('../schema/article')

const upload = multer({ dest: path.join(__dirname, '../uploads') })

const router = express.Router()

//注册局部中间件，用来解析发布文章接口的参数，其中对cover_img这个图片进行单独处理
//
router.post('/article/add', upload.single('cover_img'), expressJoi(addArticleRuler), addArticle)


module.exports = router